package com.kingmed.kmss.admin.modules.sys.controller;

import com.kingmed.kmss.admin.modules.sys.service.SysSequenceService;
import com.kingmed.kmss.common.vo.CommonResponse;
import com.kingmed.kmss.common.vo.CommonResponseHelper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 流水号 前端控制器
 * </p>
 *
 * @author liangzhi
 * @since 2023-06-08
 */
@RestController
@RequestMapping("/sys/seq")
@Api(tags = "sys流水号管理")
public class SysSequenceController {

    @Autowired
    private SysSequenceService sysSequenceService;


    @ApiOperation("生成流水号")
    @GetMapping("/genNextVal")
    public CommonResponse<String> nextVal(@RequestParam("bizKey") @ApiParam(value = "业务编码", required = true) String bizKey,
                                          @RequestParam(value = "len", required = false, defaultValue = "1") @ApiParam(value = "序号长度") Integer len,
                                          @RequestParam(value = "step", required = false, defaultValue = "1") @ApiParam(value = "步长") Integer step) {
        return CommonResponseHelper.success(bizKey+"流水编号:",sysSequenceService.genNextVal(bizKey, len, step));
    }
}
